<?php
/**
 * Class descript.
 * User: chan
 * Date: 2017/10/26 15:29
 */

namespace app\api\controller;

class Login extends Base
{
    public function login()
    {
       $login =  (new \app\api\logic\Login())->login();
       return $this->ajaxReturn($login);
    }

    public function wxAuthor()
    {
        if(!isset($this->requestData['js_code'])) return $this->ajaxReturn(['message'=>'请求错误']);
        $js_code = $this->requestData['js_code'];
        $uri = sprintf(config('wx.login_url'),config('wx.app_id'),config('wx.app_secret'),$js_code);
        $data =  (array)json_decode(httpRequest($uri));
        if(!empty($data['errcode'])) return $this->ajaxReturn(['message'=>'请求失败']);
        unset($data['expires_in']);
        unset($data['session_key']);
        unset($data['unionid']);
        return $this->ajaxReturn($data);
    }

    //注册
    public function register()
    {
      $register =  (new \app\api\logic\Login())->register();
      return $this->ajaxReturn($register);
    }


    /**
     *修改手机
     */
    public function bind()
    {
        $bind =  (new \app\api\logic\Login())->bind();
        return $this->ajaxReturn($bind);
    }


    /**
     * 梦网科技短信
     * @author tsang
     */
    public function msn(){
        $mobile = 17788715753;
        $msg = '注册短信为123456';
        $url = 'http://10.9.2.6:8082/MWGate/FunctionName.asmx/MongateCsSpSendSmsNew';
        $msg = base64_encode(iconv("UTF-8", "GBK//IGNORE", $msg));
        $params = "userId=CRMSYS&password=CRMSYS123&multixmt=*|".$mobile."|".$msg;
        echo $params;
        exit;
        $ch = curl_init();
        curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        /*curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: length

'.$params.',……'));*/
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
        curl_setopt($ch, CURLOPT_URL, $url);
        $response = curl_exec($ch);
        var_dump($response);
    }


}